<html><head><title>api.system.utils.Class</title><link rel="stylesheet" type="text/css" href="../../../../styles/main.css"><link rel="stylesheet" type="text/css" href="../../../../styles/prettify.css"><script language=JavaScript src="../../../../javascript/prettify.js"></script><script language=JavaScript src="../../../../javascript/main.js"></script></head><body class="FramedContentPage" onLoad="{NDOnLoad();prettyPrint();}"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>

<!--  Generated by Natural Docs, version 1.4 -->
<!--  http://www.naturaldocs.org  -->

<!-- saved from url=(0026)http://www.naturaldocs.org -->




<div id=Content><div class="CClass"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="api.system.utils.Class"></a>api.<wbr>system.<wbr>utils.<wbr>Class</h1><div class=CBody><p>System Utility implementation of OOP-like design concept and as well main facility for resolving dependencies, loading external classes &amp; resolving extends.</p><h4 class=CHeading>example class definition</h4><blockquote><pre class="prettyprint">Class.require('some.class.in.namespace.used.Bellow');

testClass = {
    // constructor should has the same name as the class been defined at the end
    Test : function() {
        // local variables are defined within the constructor as
        this._localA = 0;
        this.myVariable = &quot;test&quot;;

        // invoke super's constructor if needed like:
        Class.base().call(this);
    },
    method : function() {
        return this.myVariable;
    },
    method2 : function(aValue) {
        // invoke super's method if needed like:
        Class.base().call(this);

        this._localA = aValue;
    }
}

Class.define(&quot;some.namespace.Test&quot;, testClass).extend(&quot;some.other.ClassB&quot;);</pre></blockquote><h4 class=CHeading>example class loading</h4><blockquote><pre class="prettyprint">Class.require(&quot;some.namespace.Test&quot;).onloadComplete = function() {
    // here some.namespace.Test class is already loaded &amp; all its dependencies/extends are resolved.
    // you can instantiate it on your behalf.
}</pre></blockquote><h4 class=CHeading>usage notes</h4><ul><li>always import any used classes within the class&rsquo; prototype.&nbsp; That way Class.import routine will ensure that all classes are properly loaded &amp; extended upon firing onloadComplete.</li><li>always place classes in namespaces, where their physical location should be in subfolders like:</li></ul><blockquote><pre class="prettyprint">some.namespace.Test = some/namespace/Test.js</pre></blockquote><ul><li>you can import also other scripts, Class implementation does not cares what has been loaded.</li><li>do not use &ldquo;base&rdquo; as either function name or variable as it is reserved for the base/super access</li></ul><h4 class=CHeading>auto loading mechanism</h4><ul><li>when <a href="#api.system.utils.Class.import" class=LFunction id=link5 onMouseOver="ShowTip(event, 'tt5', 'link5')" onMouseOut="HideTip('tt5')">api.system.utils.Class.import</a> is invoked, the class been requested is appended into the head section of the document as script.</li><li>Then <a href="ScriptLoader-js.html#api.system.utils.ScriptLoader" class=LClass id=link6 onMouseOver="ShowTip(event, 'tt6', 'link6')" onMouseOut="HideTip('tt6')">api.system.utils.ScriptLoader</a> waits until the script is loaded.&nbsp; Once it is, browser just executes the script as natural JS and thus if the script contains other <a href="#api.system.utils.Class.import" class=LFunction id=link7 onMouseOver="ShowTip(event, 'tt5', 'link7')" onMouseOut="HideTip('tt5')">api.system.utils.Class.import</a> invokes, or <a href="#api.system.utils.Class.define" class=LFunction id=link8 onMouseOver="ShowTip(event, 'tt2', 'link8')" onMouseOut="HideTip('tt2')">api.system.utils.Class.define</a> + <a href="#api.system.utils.Class.extends" class=LFunction id=link9 onMouseOver="ShowTip(event, 'tt7', 'link9')" onMouseOut="HideTip('tt7')">api.system.utils.Class.extends</a> invokes then they get triggered, so that the <a href="ScriptLoader-js.html#api.system.utils.ScriptLoader" class=LClass id=link10 onMouseOver="ShowTip(event, 'tt6', 'link10')" onMouseOut="HideTip('tt6')">api.system.utils.ScriptLoader</a> would wait until they are loaded and resolved.</li></ul><p>All extends are handled only after the last imported script is loaded, so then they can be resolved without errors.</p><p>If ScriptLoader.setUseMinifier(true) is set then loading is handled by /utils/minifier/jsrequire.php script which does combines and minifies all the dependencies found for the load/require in question.&nbsp; For more info see <a href="ScriptLoader-js.html#api.system.utils.ScriptLoader" class=LClass id=link11 onMouseOver="ShowTip(event, 'tt6', 'link11')" onMouseOut="HideTip('tt6')">api.system.utils.ScriptLoader</a>&rsquo;s description.</p><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#api.system.utils.Class" >api.<wbr>system.<wbr>utils.<wbr>Class</a></td><td class=SDescription>System Utility implementation of OOP-like design concept and as well main facility for resolving dependencies, loading external classes &amp; resolving extends.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#api.system.utils.Class.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#api.system.utils.Class.Class" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">Class</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#api.system.utils.Class.import" >import</a></td><td class=SDescription>used to import any needed classes based on their namespace or path.</td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#api.system.utils.Class.define" id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">define</a></td><td class=SDescription>Defines a className to given classPrototype within given namespace. </td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#api.system.utils.Class.extends" >extends</a></td><td class=SDescription>Extends previously defined class with given className</td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#api.system.utils.Class.base" id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">base</a></td><td class=SDescription>used to call base function of the current executing one.</td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#api.system.utils.Class.requireUpdate" id=link4 onMouseOver="ShowTip(event, 'tt4', 'link4')" onMouseOut="HideTip('tt4')">requireUpdate</a></td><td class=SDescription>triggers autoupdate routine on the current defined classes using utils/liveupdate solution</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="api.system.utils.Class.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="api.system.utils.Class.Class"></a>Class</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>api.system.utils.Class = function()</td></tr></table></blockquote></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="api.system.utils.Class.import"></a>import</h3><div class=CBody><p>used to import any needed classes based on their namespace or path.</p><h4 class=CHeading>usage1</h4><blockquote><pre class="prettyprint">Class.require(&quot;some.namespace.Test&quot;);</pre></blockquote><h4 class=CHeading>usage2</h4><blockquote><pre class="prettyprint">Class.require(&quot;./some/namespace/Test.js&quot;);</pre></blockquote><h4 class=CHeading>usage3</h4><blockquote><pre class="prettyprint">Class.require(&quot;http://domain.org/some/namespace/Test.js&quot;);</pre></blockquote><h4 class=CHeading>returns</h4><p>loadInstance, see <a href="ScriptLoader-js.html#api.system.utils.ScriptLoader" class=LClass id=link12 onMouseOver="ShowTip(event, 'tt6', 'link12')" onMouseOut="HideTip('tt6')">api.system.utils.ScriptLoader</a></p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="api.system.utils.Class.define"></a>define</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>define : function(</td><td class=PParameter nowrap>className,</td></tr><tr><td></td><td class=PParameter nowrap>classPrototype</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Defines a className to given classPrototype within given namespace.&nbsp; Namespace is been created by <a href="Namespace-js.html#api.system.utils.Namespace" class=LClass id=link13 onMouseOver="ShowTip(event, 'tt8', 'link13')" onMouseOut="HideTip('tt8')">api.system.utils.Namespace</a> implementation.</p><h4 class=CHeading>usage</h4><blockquote><pre class="prettyprint">Class.define(&quot;some.namespace.Test&quot;, classBody);</pre></blockquote><h4 class=CHeading>returns</h4><p>Class instance, so that you can extend the defined class with some other. see &lt;api.system.utils.Class.extend&gt;</p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="api.system.utils.Class.extends"></a>extends</h3><div class=CBody><p>Extends previously defined class with given className</p><h4 class=CHeading>usage</h4><blockquote><pre class="prettyprint">Class.define(&quot;some.namespace.Test&quot;).extend(&quot;some.namespace2.Test2&quot;);</pre></blockquote></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="api.system.utils.Class.base"></a>base</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>base : function()</td></tr></table></blockquote><p>used to call base function of the current executing one.</p><h4 class=CHeading>usage</h4><blockquote><pre class="prettyprint">myClass = {
    MyClass : fucntion() {
        Class.base().call(this); // call parent's constructor, however it is named
    },
    method : function() {
        Class.base().call(this); // call parent's method
    }
}
Class.define('MyClass', myClass).extend(&quot;otherClass&quot;);</pre></blockquote></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="api.system.utils.Class.requireUpdate"></a>requireUpdate</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>requireUpdate : function(</td><td class=PParameter nowrap>className</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>triggers autoupdate routine on the current defined classes using utils/liveupdate solution</p><h4 class=CHeading>params</h4><ul><li>className full namespace+className to be updated</li></ul></div></div></div>

</div><!--Content-->



<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>api.system.utils.Class = function()</td></tr></table></blockquote></div></div><div class=CToolTip id="tt2"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>define : function(</td><td class=PParameter nowrap>className,</td></tr><tr><td></td><td class=PParameter nowrap>classPrototype</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Defines a className to given classPrototype within given namespace. </div></div><div class=CToolTip id="tt3"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>base : function()</td></tr></table></blockquote>used to call base function of the current executing one.</div></div><div class=CToolTip id="tt4"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>requireUpdate : function(</td><td class=PParameter nowrap>className</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>triggers autoupdate routine on the current defined classes using utils/liveupdate solution</div></div><div class=CToolTip id="tt5"><div class=CFunction>used to import any needed classes based on their namespace or path.</div></div><div class=CToolTip id="tt6"><div class=CClass>Utility class reposible for chained loading of external scripts.</div></div><div class=CToolTip id="tt7"><div class=CFunction>Extends previously defined class with given className</div></div><div class=CToolTip id="tt8"><div class=CClass>Creates namespace with given value. </div></div><!--END_ND_TOOLTIPS-->

<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>